Skip to content

Add availableForWrite() to HardwareSerial #2193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2014
Merged

Add availableForWrite() to HardwareSerial #2193

merged 1 commit into from
Jul 19, 2014

Conversation

PaulStoffregen
Copy link
Contributor

No description provided.

@PaulStoffregen
Copy link
Contributor Author

Bill, you probably have a good point about virtual.

Sadly, I can't keep working on this, or even keep replying.

I have far more important work to do on SPI transactions, timer & pin change events, and other features. I am also personally exhausted by the extremely long conversation. There are only so many hours in each day. I simply can't keep spending time on this feature, especially for the contributing to benefit Arduino users who purchase non-Teensy products.

Just to be absolutely clear, the development time I've spent on this feature (far more of it in conversation than actual coding) has been paid for by PJRC, by sales of Teensy.

@Chris--A
Copy link
Contributor

EDIT: I had written a reply, but misunderstood what was asked, so edited. I had assumed that availableForWrite would be marked virtual in stream/print.

Seeing as its not, you can just define your own copy in the derived class and hide it. In there you can call the base version if needed.

It would be uncommon to find a function accepting a HardwareSerial object over a Stream or Print object; Which would make this feature unusable anyway (on anything other than the most derived instance ).

@matthijskooijman
Copy link
Collaborator

@Bill, seems right what you say, except that you talk about a "wrapper class", where you probably mean "subclass" - defining a method as virtual in HardwareSerial makes sure any subclass can override the method and causes calls to it through a HardwareSerial reference or pointer to call the subclass method instead. I guess it would make sense to make this method virtual, especially if the other methods are also virtual.

@Chris--A, I think you're proposing to also put this function in the Print class? This has problems with backward compatibility, see the recent discussion on the mailing list. This pull request was intended to get te function into HardwareSerial first, while we continue to figure out how to properly put it into Print (so let's keep this PR free of discussion about that).

@Chris--A
Copy link
Contributor

Not so much proposing, I just assumed it was there already ( saw parts of the dev list ). I will go and post there when I have more input. I just do not find it useful as virtual without having it virtual in Print/Stream. HardwareSerial is quite specific compared to a generic Print, and it would not need a new definition for a function it hasn't already derived itself.

It would be better for a derived class to do as I mentioned in my last post, and either use the base version or hide it with a function of the same name ( until its integrated into Print ).

@PaulStoffregen
Copy link
Contributor Author

I agree, let's at least get this pull request merged.

When/if there's ever consensus or decision on the Print or Stream class, it's pretty trivial to add virtual.

cmaglie added a commit that referenced this pull request Jul 19, 2014
Add availableForWrite() to HardwareSerial
@cmaglie cmaglie merged commit e5c7cb9 into arduino:ide-1.5.x Jul 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants